<!DOCTYPE html>
<html>
  <head>
     
    <meta charset="UTF-8">
    <title>Apex上传文件至Windows网盘 - 我的元宇宙</title>
    <link rel="shortcut icon" href="/static/img/icon.png">
    <link rel="icon" href="/static/img/icon.png" sizes="192x192"/>
    
<link rel="stylesheet" href="/static/kico.css">
<link rel="stylesheet" href="/static/hingle.css">

    
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/FortAwesome/Font-Awesome/css/font-awesome.min.css">

    <meta name="viewport" content="width=device-width, maximum-scale=1, initial-scale=1"/>
    <meta property="og:site_name" content="我的元宇宙">
    <meta property="og:title" content="Apex上传文件至Windows网盘"/>
    
 
<meta name="generator" content="Hexo 5.4.0"></head>

  <body>
    <header>
    <div class="head-title">
        <h4>我的元宇宙</h4>
    </div>
    <div class="head-action">
        <div class="toggle-btn"></div>
        <div class="light-btn"></div>
        <div class="search-btn"></div>
    </div>
    <form class="head-search" method="post">
        <input type="text" name="s" placeholder="搜索什么？">
    </form>
    <nav class="head-menu">
        <a href="/">首页</a>
        <div class="has-child">
            <a>分类</a>
            <div class="sub-menu">
                <a class="category-link" href="/categories/%E5%AD%A6%E4%B9%A0/">学习</a><a class="category-link" href="/categories/%E6%9D%82%E9%A1%B9/">杂项</a><a class="category-link" href="/categories/%E7%AC%94%E8%AE%B0/">笔记</a><a class="category-link" href="/categories/%E8%BD%AC%E8%BD%BD/">转载</a>
            </div>
        </div>
        
            <a href="/about">关于我</a>
        
    </nav>
</header>

    <main>
    <div class="wrap min">
        <section class="post-title">
            <h2>Apex上传文件至Windows网盘</h2>
            <div class="post-meta">
                <time class="date">2021.11.05</time>
            
                <span class="category"><a class="category-link" href="/categories/%E7%AC%94%E8%AE%B0/">笔记</a>，<a class="category-link" href="/categories/%E7%AC%94%E8%AE%B0/Oracle/">Oracle</a>，<a class="category-link" href="/categories/%E7%AC%94%E8%AE%B0/Oracle/Apex/">Apex</a></span>
            
            </div>
        </section>
        <article class="post-content">
        
            <h1 id="Apex-上传文件至Windows网盘"><a href="#Apex-上传文件至Windows网盘" class="headerlink" title="Apex 上传文件至Windows网盘"></a>Apex 上传文件至Windows网盘</h1><h2 id="1-前期工作"><a href="#1-前期工作" class="headerlink" title="1.前期工作"></a>1.前期工作</h2><h3 id="1-服务端挂载网盘"><a href="#1-服务端挂载网盘" class="headerlink" title="1. 服务端挂载网盘"></a>1. 服务端挂载网盘</h3><ol>
<li><p>安装 <code>cifs-utils</code></p>
<ul>
<li>yum install cifs-utils</li>
</ul>
</li>
<li><p>参考文档</p>
<p> <a target="_blank" rel="noopener" href="http://blog.chinaunix.net/uid-23177306-id-2531117.html">Linux下Oracle不支持cifs?</a></p>
<p> <a target="_blank" rel="noopener" href="http://bbs.chinaunix.net/thread-2125748-1-1.html">Linux访问Windows共享文件夹，关于mount cifs的一个问题</a></p>
</li>
<li><p>挂载网盘</p>
 <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">&lt;!--查看oracle本地uid,gid等--&gt;</span><br><span class="line">[oracle@xxxxxx u01]$ id</span><br><span class="line">uid=1002(oracle) gid=1002(oinstall) groups=1002(oinstall),1003(dba)</span><br><span class="line">context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023</span><br><span class="line">&lt;!--挂载目录--&gt;</span><br><span class="line">[root@xxxxxx ~]<span class="comment"># mount -t cifs //xx.xx.xx.xxx/xxxxx -o uid=1002,gid=1002,rw,domain=xxxxxx,username=xxxxxx,nolock  /u01/Upload/share_data</span></span><br><span class="line">Password <span class="keyword">for</span> xxxxxx@//xx.xx.xx.xxx/xxxxx:  ********************</span><br><span class="line">&lt;!--验证目录权限--&gt;</span><br><span class="line">[root@xxxxxx ~]<span class="comment"># ll /u01/Upload/share_data</span></span><br><span class="line">总用量 45749</span><br><span class="line">-rwxr-xr-x. 1 oracle oinstall   573174 6月  16 11:02 2019-2020-原表.xlsx</span><br><span class="line">&lt;!--可选卸载 挂载--&gt;</span><br><span class="line">[root@xxxxxx ~]<span class="comment"># umount /u01/Upload/share_data</span></span><br><span class="line"></span><br></pre></td></tr></table></figure></li>
</ol>
<h3 id="2-在oracle中添加目录"><a href="#2-在oracle中添加目录" class="headerlink" title="2. 在oracle中添加目录"></a>2. 在oracle中添加目录</h3><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="keyword">create</span> <span class="keyword">or</span> replace directory DFS_SHARE_DATA <span class="keyword">as</span> <span class="string">&#x27;/u01/Upload/share_data&#x27;</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">-- 2、查询有哪些directory</span></span><br><span class="line"><span class="keyword">select</span> <span class="operator">*</span></span><br><span class="line"><span class="keyword">from</span> dba_directories;</span><br><span class="line"><span class="comment">-- 3、赋权</span></span><br><span class="line"><span class="comment">-- grant read,write on directory DFS_SHARE_DATA to user01;</span></span><br><span class="line"><span class="comment">-- 4、删除</span></span><br><span class="line"><span class="keyword">drop</span> directory DFS_SHARE_DATA;</span><br><span class="line"><span class="comment">-- 5、测试</span></span><br><span class="line"><span class="keyword">DECLARE</span></span><br><span class="line">    filehandle utl_file.file_type; <span class="comment">--句柄</span></span><br><span class="line"><span class="keyword">begin</span></span><br><span class="line">    <span class="comment">--打开文件</span></span><br><span class="line">    filehandle :<span class="operator">=</span> utl_file.fopen(<span class="string">&#x27;DFS_SHARE_DATA&#x27;</span>, <span class="string">&#x27;daas-1.py&#x27;</span>, <span class="string">&#x27;w&#x27;</span>); </span><br><span class="line">    <span class="comment">--写入一行记录</span></span><br><span class="line">    utl_file.put_line(filehandle, <span class="string">&#x27;# -*- coding: utf-8 -*-&#x27;</span>);</span><br><span class="line">    utl_file.put_line(filehandle, <span class="string">&#x27;print(&quot;hi)&#x27;</span>);</span><br><span class="line">    <span class="comment">--关闭句柄</span></span><br><span class="line">    utl_file.fclose(filehandle);</span><br><span class="line"><span class="keyword">end</span>;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="3-创建对应包并使用"><a href="#3-创建对应包并使用" class="headerlink" title="3. 创建对应包并使用"></a>3. 创建对应包并使用</h3><ol>
<li><p>PL/SQL包</p>
 <figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">create</span> <span class="keyword">or</span> replace PACKAGE UploadFilePackage <span class="keyword">as</span></span><br><span class="line"><span class="comment">-- Doc https://docs.oracle.com/en/database/oracle/oracle-database/20/arpls/UTL_FILE.html</span></span><br><span class="line"><span class="comment">-- 从apex_application_temp_files 中取BOLB数据 写入文件夹中</span></span><br><span class="line"><span class="comment">-- P_Key(外建id) + &#x27;_&#x27; + 文件名做唯一主键</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="keyword">procedure</span> WriteBlobToUploadFile(P_Fileitem <span class="keyword">IN</span> VARCHAR2, P_Appid <span class="keyword">IN</span> VARCHAR2,</span><br><span class="line">                                    P_DirObject <span class="keyword">IN</span> VARCHAR2, P_Key <span class="keyword">IN</span> VARCHAR2);</span><br><span class="line"><span class="comment">--  根据文件名(P_Key(外建id) + &#x27;_&#x27; + 文件名) 读文件并 提供下载请求</span></span><br><span class="line"><span class="comment">--  如:</span></span><br><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment">begin</span></span><br><span class="line"><span class="comment">    UploadFilePackage.ReadUploadFileToDownload(:P460_ID_FILENAME, :GLOBAL_PAYMENT_DIR);</span></span><br><span class="line"><span class="comment">end;</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line">    <span class="keyword">procedure</span> ReadUploadFileToDownload(P_Filename <span class="keyword">in</span> VARCHAR2, P_DirObject <span class="keyword">in</span> VARCHAR2,</span><br><span class="line">                                    P_Mimetype <span class="keyword">in</span> varchar2 <span class="keyword">default</span> <span class="string">&#x27;text/plain&#x27;</span>);</span><br><span class="line"><span class="comment">--  根据文件名(P_Key(外建id) + &#x27;_&#x27; + 文件名) 删除文件</span></span><br><span class="line"><span class="comment">--  如:</span></span><br><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment">declare</span></span><br><span class="line"><span class="comment">    V_FileName              varchar2(100);</span></span><br><span class="line"><span class="comment">    V_Payment_Directory     varchar2(2000) := :GLOBAL_PAYMENT_DIR;</span></span><br><span class="line"><span class="comment">    V_Outsourcing_Directory varchar2(2000) := :GLOBAL_OUTSOURCING_DIR;</span></span><br><span class="line"><span class="comment">    V_Procurement_Directory varchar2(2000) := :GLOBAL_PROCUREMENT_DIR;</span></span><br><span class="line"><span class="comment">    V_Maintenance_Directory varchar2(2000) := :GLOBAL_MAINTENANCE_DIR;</span></span><br><span class="line"><span class="comment">begin</span></span><br><span class="line"><span class="comment">    --  删除表中记录</span></span><br><span class="line"><span class="comment">    select PDF_FILENAME into V_FileName from XXXXXX where id = :P13_ID;</span></span><br><span class="line"><span class="comment">    DELETE XXXXXX where id = :P13_ID;</span></span><br><span class="line"><span class="comment">    if :P13_PAYMENT_ID is not null then</span></span><br><span class="line"><span class="comment">        -- 删除网盘文件</span></span><br><span class="line"><span class="comment">        UploadFilePackage.DeleteUploadFile(</span></span><br><span class="line"><span class="comment">                P_Filename =&gt; V_FileName,</span></span><br><span class="line"><span class="comment">                P_DirObject =&gt; V_Payment_Directory);</span></span><br><span class="line"><span class="comment">    end if;</span></span><br><span class="line"><span class="comment">    commit;</span></span><br><span class="line"><span class="comment">end;</span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line">    <span class="keyword">procedure</span> DeleteUploadFile(P_Filename <span class="keyword">in</span> VARCHAR2, P_DirObject <span class="keyword">in</span> VARCHAR2);</span><br><span class="line"><span class="keyword">end</span> UploadFilePackage;</span><br><span class="line"><span class="keyword">create</span> <span class="keyword">or</span> replace PACKAGE BODY UploadFilePackage <span class="keyword">as</span></span><br><span class="line">    <span class="keyword">PROCEDURE</span> WriteBlobToUploadFile(P_Fileitem <span class="keyword">IN</span> VARCHAR2, P_Appid <span class="keyword">IN</span> VARCHAR2,</span><br><span class="line">                                    P_DirObject <span class="keyword">IN</span> VARCHAR2, P_Key <span class="keyword">IN</span> VARCHAR2)</span><br><span class="line">        <span class="keyword">IS</span></span><br><span class="line">        v_blob        <span class="type">BLOB</span>;</span><br><span class="line">        v_filename    varchar2(<span class="number">2000</span>);</span><br><span class="line">        v_buffer      RAW(<span class="number">32767</span>);</span><br><span class="line">        blob_length   <span class="type">INTEGER</span>;</span><br><span class="line">        out_file      UTL_FILE.FILE_TYPE;</span><br><span class="line">        chunk_size    BINARY_INTEGER :<span class="operator">=</span> <span class="number">32767</span>;</span><br><span class="line">        blob_position <span class="type">INTEGER</span>        :<span class="operator">=</span> <span class="number">1</span>;</span><br><span class="line">        vErrMsg       VARCHAR2(<span class="number">2000</span>);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">BEGIN</span></span><br><span class="line">        <span class="comment">--     substr(&#x27;171686777406224703//trusted.xml&#x27;,  instr(&#x27;171686777406224703/trusted.xml&#x27;, &#x27;/&#x27;)+1,length(&#x27;171686777406224703/trusted.xml&#x27;))</span></span><br><span class="line">        v_filename :<span class="operator">=</span> substr(P_Fileitem, instr(P_Fileitem, <span class="string">&#x27;/&#x27;</span>) <span class="operator">+</span> <span class="number">1</span>, length(P_Fileitem));</span><br><span class="line"></span><br><span class="line">        v_filename :<span class="operator">=</span> P_Key <span class="operator">||</span> <span class="string">&#x27;_&#x27;</span> <span class="operator">||</span> v_filename;</span><br><span class="line">        apex_debug.message(<span class="string">&#x27;--------UploadFileNmae-------&#x27;</span>);</span><br><span class="line">        apex_debug.message(v_filename);</span><br><span class="line">        <span class="comment">-- Retrieve the BLOB for reading</span></span><br><span class="line">        <span class="keyword">BEGIN</span></span><br><span class="line">            <span class="keyword">SELECT</span> blob_content</span><br><span class="line">            <span class="keyword">INTO</span> v_blob</span><br><span class="line">            <span class="keyword">FROM</span> apex_application_temp_files</span><br><span class="line">            <span class="keyword">WHERE</span> name <span class="operator">=</span> P_Fileitem</span><br><span class="line">            <span class="keyword">and</span> application_id <span class="operator">=</span> P_Appid;</span><br><span class="line">        EXCEPTION</span><br><span class="line">            <span class="keyword">WHEN</span> OTHERS <span class="keyword">THEN</span></span><br><span class="line">                vErrMsg :<span class="operator">=</span> <span class="string">&#x27;No data found&#x27;</span>;</span><br><span class="line">        <span class="keyword">END</span>;</span><br><span class="line">        <span class="comment">-- 检索BLOB的大小</span></span><br><span class="line">        blob_length :<span class="operator">=</span> DBMS_LOB.GETLENGTH(v_blob);</span><br><span class="line"></span><br><span class="line">        <span class="comment">--  打开要写入blob的位置的句柄</span></span><br><span class="line">        <span class="comment">-- 注意:“wb”参数表示“以字节模式写入”，并且只有可在UTL_FILE pkg中使用Oracle 10g或更高版本。</span></span><br><span class="line">        <span class="comment">-- 使用&#x27;w&#x27;代替pre Oracle 10q数据库。</span></span><br><span class="line">        out_file :<span class="operator">=</span> UTL_FILE.FOPEN(P_DirObject, v_filename, <span class="string">&#x27;wb&#x27;</span>, chunk_size);</span><br><span class="line">        <span class="comment">-- 将BLOB以块的形式写入文件</span></span><br><span class="line">        WHILE blob_position <span class="operator">&lt;=</span> blob_length</span><br><span class="line">            LOOP</span><br><span class="line">                IF ((blob_position <span class="operator">+</span> chunk_size <span class="operator">-</span> <span class="number">1</span>) <span class="operator">&gt;</span> blob_length) <span class="keyword">THEN</span></span><br><span class="line">                    chunk_size :<span class="operator">=</span> blob_length <span class="operator">-</span> blob_position <span class="operator">+</span> <span class="number">1</span>;</span><br><span class="line">                <span class="keyword">END</span> IF;</span><br><span class="line">                dbms_lob.read(v_blob, chunk_size, blob_position, v_buffer);</span><br><span class="line">                UTL_FILE.put_raw(out_file, v_buffer, <span class="literal">TRUE</span>);</span><br><span class="line">                blob_position :<span class="operator">=</span> blob_position <span class="operator">+</span> chunk_size;</span><br><span class="line">            <span class="keyword">END</span> LOOP;</span><br><span class="line">        UTL_FILE.FCLOSE(out_file);</span><br><span class="line">        <span class="keyword">delete</span> apex_application_temp_files <span class="keyword">WHERE</span> name <span class="operator">=</span> P_Fileitem <span class="keyword">and</span> application_id <span class="operator">=</span> P_Appid;</span><br><span class="line">    EXCEPTION</span><br><span class="line">        <span class="keyword">WHEN</span> OTHERS <span class="keyword">THEN</span></span><br><span class="line">            apex_debug.warn(<span class="string">&#x27;-----WriteBlobToUploadFile: Error----------&#x27;</span>);</span><br><span class="line">            IF UTL_FILE.IS_OPEN(out_file) <span class="keyword">THEN</span></span><br><span class="line">                UTL_FILE.FCLOSE(out_file);</span><br><span class="line">            <span class="keyword">END</span> IF;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="keyword">END</span> WriteBlobToUploadFile;</span><br><span class="line">    <span class="keyword">Procedure</span> ReadUploadFileToDownload(P_Filename <span class="keyword">in</span> VARCHAR2, P_DirObject <span class="keyword">in</span> VARCHAR2,</span><br><span class="line">                                    P_Mimetype <span class="keyword">in</span> varchar2 <span class="keyword">default</span> <span class="string">&#x27;text/plain&#x27;</span>)</span><br><span class="line">        <span class="keyword">IS</span></span><br><span class="line">        v_lob         <span class="type">BLOB</span>;</span><br><span class="line">        v_BFile       BFILE;</span><br><span class="line">        v_src_offset  NUMBER :<span class="operator">=</span> <span class="number">1</span>;</span><br><span class="line">        v_dest_offset NUMBER :<span class="operator">=</span> <span class="number">1</span>;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">BEGIN</span></span><br><span class="line">        dbms_lob.createtemporary(v_lob, <span class="literal">FALSE</span>, DBMS_LOB.SESSION);</span><br><span class="line">        v_BFile :<span class="operator">=</span> BFileName(P_DirObject, P_Filename);</span><br><span class="line"></span><br><span class="line">        dbms_lob.fileOpen(v_BFile);</span><br><span class="line">        dbms_lob.loadblobfromfile(dest_lob <span class="operator">=</span><span class="operator">&gt;</span> v_lob,</span><br><span class="line">                                src_bfile <span class="operator">=</span><span class="operator">&gt;</span> v_BFile,</span><br><span class="line">                                amount <span class="operator">=</span><span class="operator">&gt;</span> dbms_lob.getLength(v_BFile),</span><br><span class="line">                                dest_offset <span class="operator">=</span><span class="operator">&gt;</span> v_dest_offset,</span><br><span class="line">                                src_offset <span class="operator">=</span><span class="operator">&gt;</span> v_src_offset);</span><br><span class="line">        dbms_lob.fileClose(v_BFile);</span><br><span class="line"></span><br><span class="line">        <span class="comment">--download file</span></span><br><span class="line">        htp.init;</span><br><span class="line"><span class="comment">--     https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types</span></span><br><span class="line">        owa_util.mime_header(P_Mimetype, <span class="literal">false</span>);</span><br><span class="line">        htp.p(<span class="string">&#x27;Content-length: &#x27;</span> <span class="operator">||</span> sys.dbms_lob.getlength(v_lob));</span><br><span class="line">        htp.p(<span class="string">&#x27;Content-Disposition: attachment; filename=&quot;&#x27;</span> <span class="operator">||</span> P_Filename <span class="operator">||</span> <span class="string">&#x27;&quot;&#x27;</span>);</span><br><span class="line">        htp.p(<span class="string">&#x27;Cache-Control: max-age=3600&#x27;</span>); <span class="comment">-- 浏览器缓存一个小时，根据需要进行调整</span></span><br><span class="line">        owa_util.http_header_close;</span><br><span class="line">        wpg_docload.download_file(v_lob);</span><br><span class="line">        apex_application.stop_apex_engine;</span><br><span class="line">    <span class="keyword">End</span> ReadUploadFileToDownload;</span><br><span class="line">    <span class="keyword">procedure</span> DeleteUploadFile(P_Filename <span class="keyword">in</span> VARCHAR2, P_DirObject <span class="keyword">in</span> VARCHAR2)</span><br><span class="line">        <span class="keyword">is</span></span><br><span class="line">    <span class="keyword">begin</span></span><br><span class="line"></span><br><span class="line">        UTL_FILE.FREMOVE(P_DirObject, P_Filename);</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="keyword">end</span> DeleteUploadFile;</span><br><span class="line"><span class="keyword">end</span> UploadFilePackage;</span><br><span class="line"></span><br></pre></td></tr></table></figure></li>
<li><p>下载地址</p>
 <figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="keyword">select</span> PAYMENT_ID,</span><br><span class="line">    <span class="built_in">listagg</span>(concat(concat(concat(concat(<span class="string">&#x27;&lt;a href=&quot;&#x27;</span>,</span><br><span class="line">                                        APEX_PAGE.GET_URL(p_page<span class="operator">=</span><span class="operator">&gt;</span>:APP_PAGE_ID,</span><br><span class="line">                                                            p_items<span class="operator">=</span><span class="operator">&gt;</span><span class="string">&#x27;P460_ID_FILENAME&#x27;</span>,</span><br><span class="line">                                                            p_values<span class="operator">=</span><span class="operator">&gt;</span>PDF_FILENAME,</span><br><span class="line">                                                            p_request<span class="operator">=</span><span class="operator">&gt;</span><span class="string">&#x27;DownloadUploadFile&#x27;</span>))</span><br><span class="line">                                , <span class="string">&#x27;&quot;&gt;&#x27;</span>), PDF_FILENAME), <span class="string">&#x27;&lt;/a&gt;&#x27;</span>), <span class="string">&#x27;&lt;br&gt;&#x27;</span>)</span><br><span class="line">            <span class="keyword">within</span> <span class="keyword">group</span> (<span class="keyword">order</span> <span class="keyword">by</span> PAYMENT_ID) <span class="keyword">as</span> DownloadRrl</span><br><span class="line"><span class="keyword">from</span> xxxxxx</span><br><span class="line"><span class="keyword">group</span> <span class="keyword">by</span> PAYMENT_ID</span><br></pre></td></tr></table></figure></li>
</ol>

        </article>
        <section class="post-near">
            <ul>
                
                    <li>上一篇: <a href="/2021/12/13/3449662a057f/">Oracle Apex IR 多选批量处理后页面局部刷新</a></li>
                
                
                    <li>下一篇: <a href="/2021/11/05/b209999e9b35/">Apex对接钉钉免登</a></li>
                
            </ul>
        </section>
        
            <section class="post-tags">
            <a class="-none-link" href="/tags/Apex/" rel="tag">Apex</a><a class="-none-link" href="/tags/Windows/" rel="tag">Windows</a><a class="-none-link" href="/tags/%E5%85%83%E5%AE%87%E5%AE%99/" rel="tag">元宇宙</a><a class="-none-link" href="/tags/%E7%BD%91%E7%9B%98/" rel="tag">网盘</a>
            </section>
        
    
        <section class="post-author">
        
            <figure class="author-avatar">
                <!-- <img src="https://metaverse-1256174970.cos.ap-shanghai.myqcloud.com/image_%2Fahmed-mulla-hS-2bYjeyWc-unsplash.jpg" alt="Pan" /> -->
                <img src="https://nuczmjfhvndrjhrfpqkcyeimmdrcsebw.oss-cn-shanghai.aliyuncs.com/jbfffurvdqmpvhukbzbsea/QPWp3GjspHEz8QHi6RDm.jpeg" alt="Pan" >
            </figure>
        
            <div class="author-info">
                <h4>Pan</h4>
                <p>社会主义螺丝钉,币圈韭菜,A股韭菜</p>
            </div>
        </section>
    
    </div>
</main>

    <footer>
    <div class="buttons">
        <a class="to-top" href="#"></a>
    </div>
    <div class="wrap min">
        <section class="widget">
            <div class="row">
                <div class="col-m-4">
                    <h3 class="title-recent">最新文章：</h3>
                    <ul class="post-list"><li class="post-list-item"><a class="post-list-link" href="/2022/05/01/0586406b1d50/">不同衣物收纳教程</a></li><li class="post-list-item"><a class="post-list-link" href="/2022/01/13/6578eb87a21b/">Apex直传阿里云OSS</a></li><li class="post-list-item"><a class="post-list-link" href="/2021/12/13/3449662a057f/">Oracle Apex IR 多选批量处理后页面局部刷新</a></li><li class="post-list-item"><a class="post-list-link" href="/2021/11/05/60190b5049e6/">Apex上传文件至Windows网盘</a></li><li class="post-list-item"><a class="post-list-link" href="/2021/11/05/b209999e9b35/">Apex对接钉钉免登</a></li><li class="post-list-item"><a class="post-list-link" href="/2021/11/05/e7f888284497/">Oracle AES加解密Demo</a></li></ul>
                </div>
                <div class="col-m-4">
                    <h3 class="title-date">时光机：</h3>
                    <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2022/05/">五月 2022</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2022/01/">一月 2022</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/12/">十二月 2021</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/11/">十一月 2021</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/06/">六月 2020</a></li></ul>
                </div>
                <div class="col-m-4">
                    <h3 class="title-tags">标签云：</h3>
                    <a href="/tags/AES/" style="font-size: 10px;">AES</a> <a href="/tags/Apex/" style="font-size: 16.67px;">Apex</a> <a href="/tags/CSS/" style="font-size: 10px;">CSS</a> <a href="/tags/HTML/" style="font-size: 10px;">HTML</a> <a href="/tags/JS/" style="font-size: 10px;">JS</a> <a href="/tags/Nginx/" style="font-size: 10px;">Nginx</a> <a href="/tags/OSS/" style="font-size: 10px;">OSS</a> <a href="/tags/Oracle/" style="font-size: 13.33px;">Oracle</a> <a href="/tags/Ords/" style="font-size: 10px;">Ords</a> <a href="/tags/PL-SQL/" style="font-size: 10px;">PL/SQL</a> <a href="/tags/SQLcl/" style="font-size: 10px;">SQLcl</a> <a href="/tags/Tomcat/" style="font-size: 10px;">Tomcat</a> <a href="/tags/Windows/" style="font-size: 10px;">Windows</a> <a href="/tags/%E5%85%83%E5%AE%87%E5%AE%99/" style="font-size: 20px;">元宇宙</a> <a href="/tags/%E5%A4%9C%E8%AF%BB/" style="font-size: 13.33px;">夜读</a> <a href="/tags/%E6%9D%82%E9%A1%B9/" style="font-size: 10px;">杂项</a> <a href="/tags/%E7%BD%91%E7%9B%98/" style="font-size: 10px;">网盘</a> <a href="/tags/%E8%BD%AC%E8%BD%BD/" style="font-size: 13.33px;">转载</a> <a href="/tags/%E9%92%89%E9%92%89/" style="font-size: 10px;">钉钉</a> <a href="/tags/%E9%98%BF%E9%87%8C%E4%BA%91/" style="font-size: 10px;">阿里云</a>
                </div>
            </div>
        </section>
        <section class="sub-footer">
            <p>友链:<a href="https://wangfanggang.com/" target="_blank">钢钢更新</a></p>
            <p><span>用于分享个人成长经历,日常状况.心情感悟,分享Apex开发经验,Python开发经验,Go等一系列学习笔记.作为网络知识储备.也会记录一些网络金句</span></p>
            <p>© 2022 
                <a href="/">我的元宇宙</a>. All Rights Reserved. Theme By 
                <a href="https://github.com/Dreamer-Paul/Hingle" target="_blank" rel="nofollow">Hingle</a>.
                <a target="_blank" rel="noopener" href="https://beian.miit.gov.cn/">豫ICP备19030991号</a></p>
        </section>
    </div>
    
</footer>


<script src="/static/kico.js"></script>
<script src="/static/hingle.js"></script>


<script>var hingle = new Paul_Hingle({"copyright":true,"night":true});</script>

  </body>
</html>
